import strutils, sequtils

proc clean*(number: string): string = 
  result = number.filterIt(it in Digits).join
  if result.len == 11 and result[0] == '1':
    result = result[1..^1]

  if result.len != 10 or result[0] in {'1', '0'} or result[3] in {'1', '0'}:
    raise newException(ValueError, "invalid")
